<!DOCTYPE html>
<html>

{include file='public/header'}
<style>
    .copy{cursor: pointer;}
</style>
<body>
    <div class="x-nav">
        <span class="layui-breadcrumb">
            <a href="javascript:void(0)">首页</a>
            <a href="javascript:void(0)">账号管理</a>
            <a><cite>负责人账号</cite></a>
        </span>
        <a class="layui-btn layui-btn-small" id="reload" title="刷新">
            <i class="layui-icon" style="line-height:30px"><i class="iconfont">&#xe6aa;</i></i>
        </a>
    </div>
    <div class="x-body">
        <div class="layui-row">
            <form class="layui-form">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">负责人名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" placeholder="请输入负责人名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">所属公司名称：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="company_name" placeholder="请输入所属公司名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">是否分销商：</label>
                    <div class="layui-input-inline">
                        <select name="is_distributor" id="is_distributor">
                            <option value="">请选择</option>
                            <option value="0">否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">是否分公司负责人：</label>
                    <div class="layui-input-inline">
                        <select name="is_branch_office_manage" id="is_branch_office_manage">
                            <option value="">请选择</option>
                            <option value="0">否</option>
                            <option value="1">是</option>
                        </select>
                    </div>
                </div>
                <button class="layui-btn" style="margin-left: 10px;" lay-submit lay-filter="searchList">搜索</button>
                <button type="reset" id="resetList" class="layui-btn layui-btn-primary">重置</button>
            </form>
        </div>
        <table id="responsibilityPerson" lay-filter="responsibilityPerson"></table>
    </div>
    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="add">添加负责人</button>
        </div>
    </script>
    <script type="text/html" id="tbBar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <!-- <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a> -->
    </script>
    <script>
        let params = {
            elem: '#responsibilityPerson'
            , toolbar: '#toolbarDemo'
            , url: '{:url("admin/responsibilityPerson/list")}' //数据接口
            , id: 'responsibilityPerson'
            , page:true
            , limit:15
            , cols: [[ //表头
                { field: 'id', title: 'ID', width: 100, sort: true, align:'center' }
                , { field: 'name', title: '负责人名称', align:'center' }
                , { field: 'company_name', title: '公司名称', align:'center' }
                , { field: 'p_name', title: '上级分销商/分公司名称', width:200, align:'center' }
                , { field: 'is_branch_office_manage', title: '是否分公司管理', width: 130, align:'center' , templet: function (d) {
                        return d.is_branch_office_manage == 1 ? '是' : '否'
                    }
                }
                , { field: 'is_distributor', title: '是否分销商', width: 120, align:'center' , templet: function (d) {
                        return d.is_distributor == 1 ? '是' : '否'
                    }
                }
                , { field: 'token', title: 'token',align:'center' , templet: function (d) {
                        let token = d.token
                        return token ? `<i class="layui-icon layui-icon-file-b copy" onclick="copyContent(this)" data-value='${token}'></i>${token}` : ''
                    }
                }
                , { field: 'scale', title: '分成比例(%)', width: 110,align:'center' }
                , { field: 'commission_scale', title: '手续费比例(%)', width: 130,align:'center' }
                , { field: 'wechat_applet_commission_scale', title: '微信小程序官方手续费比例(%)', width: 220,align:'center' }
                , { field: 'is_depart', title: '状态', width: 120, align:'center' , templet: function (d) {
                        return d.is_depart == 1 ? '离职' : '在职'
                    }
                }
                , { toolbar: '#tbBar', title: '操作', width: 100,align:'center' }
            ]],
        }
        tableList(params)

        layui.use('table', function () {
            var table = layui.table;
            table.on('toolbar(responsibilityPerson)', function (obj) {
                var event = obj.event;
                if (event === 'add') {
                    x_admin_show('添加负责人', './info.html', 650, 650);
                }
            });
            table.on('tool(responsibilityPerson)', function (obj) {
                var event = obj.event;
                if (event === 'del') {
                    DeleteAjax('/admin/responsibilityPerson/delete',{ id: obj.data.id },'responsibilityPerson')
                } else if (event === 'edit') {
                    x_admin_show('编辑负责人', `./info.html?id=${obj.data.id}`, 650, 650);
                }
            });

        });

    </script>
</body>

</html>